<template>
	<view>
		<cu-custom bgColor="bg-gradual-red" :isBack="false">
			<block slot="backText">返回</block>
			<block slot="content">我的</block>
		</cu-custom>
		<view class="cu-card" v-if="hasLogin">
			<view class="cu-item shadow">
				<view class="cu-form-group">
					<view class="title text-bold">用户名</view>
					<input type="text" :value="userName" disabled/>
				</view>
				<view class="cu-form-group">
					<view class="title text-bold">姓　名</view>
					<input type="text" :value="name" disabled/>
				</view>
				<view class="cu-form-group">
					<view class="title text-bold">部　门</view>
					<input type="text" :value="deptName" disabled/>
				</view>
				<view class="cu-form-group">
					<view class="title text-bold">服务器</view>
					<input type="text" :value="server.name" disabled/>
				</view>
			</view>
		</view>
		<view class="flex margin-top padding-lr" v-if="hasLogin">
			<button class="cu-btn shadow flex-sub bg-purple padding-sm margin-xs radius" @tap="bindPwd">修改密码</button>
			<button class="cu-btn shadow flex-sub bg-grey padding-sm margin-xs radius" @tap="bindLogout">注销</button>
		</view>
		
		<view class="padding flex flex-direction"  v-if="!hasLogin">
			<!-- <button class="cu-btn bg-red margin-tb-sm lg" @tap="to_chang">切换服务器</button> -->
			<button class="cu-btn bg-red margin-tb-sm lg" @tap="to_login">登录</button>
		</view>
		
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		computed:{
			...mapState(['hasLogin','userName','name','deptName','server'])
		},
		data() {
			return {
				
			}
		},
		methods: {
			...mapMutations(['logout']),
			to_login(){
				uni.redirectTo({
					url: '../me/login'
				});
			},
			bindLogout(){
				this.logout();
				uni.redirectTo({
					url: '../me/login'
				});
			},
			bindPwd(){
				uni.navigateTo({
					url: '../me/pwd'
				});
			}			
		}
	}
</script>

<style>

</style>
